<?
class Vakanz_Relations extends Vakanz_CRM_Db_Table {
	protected $_name = 'crm_relation';
	protected $_primary = 'relation_autoid';

	protected $_rowClass = 'Vakanz_Relation';
	protected $_dependentTables = array('Vakanz_Relation_Attributes');

	public function fetchAll($select = null) {
		if (is_null($select)) {
			$select = $this->select();
		}
		if (is_a($select,'Zend_Db_Table_Select') ) {
			$select->where('relation_status = ?', 10);
		}
		return parent::fetchAll($select);
	}
	/**
	 * Get a relation
	 *
	 * @param int $relation_id
	 * @return Vakanz_Relation
	 */
	public function getRelation($relation_id, $status = 10, $timestamp = null) {
		return $this->fetchAll($this->select()->where('relation_id = ?', $relation_id))->current();
	}
}